package com.ewzj.bigdata.mvp.model

import com.ewzj.bigdata.app.config.netmodel.CommonService
import com.ewzj.bigdata.app.extensions.json2Body
import com.ewzj.bigdata.mvp.contract.MapActivityContract
import com.ewzj.bigdata.mvp.model.reqbean.Reqmaphomelist
import com.ewzj.bigdata.mvp.model.reqbean.Reqpagebean
import com.ewzj.bigdata.mvp.model.rspbean.BaseData
import com.ewzj.bigdata.mvp.model.rspbean.BaseListData
import com.ewzj.bigdata.mvp.model.rspbean.HomeBean
import com.google.gson.Gson
import com.jess.arms.integration.IRepositoryManager
import com.jess.arms.mvp.BaseModel
import io.reactivex.Observable
import javax.inject.Inject

/**
 * author:zhangjing
 * 作用:
 * return:
 */
class MapActivityModel @Inject constructor(val mGson :Gson,repositoryManager: IRepositoryManager) :BaseModel(repositoryManager),MapActivityContract.Model{
    val service=repositoryManager.obtainRetrofitService(CommonService::class.java)

    override fun loadNewAreaDatas() : Observable<BaseData<BaseListData<HomeBean>>> {
        var reqpage=Reqpagebean()
        reqpage.is_map="1"
        return service.newhomeV3(json2Body(mGson.toJson(reqpage)))
    }

    override fun loadOldAreaDatas() : Observable<BaseData<BaseListData<HomeBean>>>{
        var reqpage=Reqpagebean()
        reqpage.is_map="1"
        return service.oldhomeV3(json2Body(mGson.toJson(reqpage)))
    }

    override fun loadRentAreaDatas() :Observable<BaseData<BaseListData<HomeBean>>>{
        var reqpage=Reqpagebean()
        reqpage.is_map="1"
        return service.renthomeV3(json2Body(mGson.toJson(reqpage)))
    }

    override fun getRentlist(reqmaphomelist: Reqmaphomelist): Observable<BaseData<BaseListData<HomeBean>>> {
        return service.getMapRentHomelist(json2Body(mGson.toJson(reqmaphomelist)))
    }

    override fun getershoulist(reqmaphomelist: Reqmaphomelist): Observable<BaseData<BaseListData<HomeBean>>> {
        return service.getMapOldHomelist(json2Body(mGson.toJson(reqmaphomelist)))
    }
}